#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
using namespace std;

class Date {
public:
    Date(size_t a, size_t b, size_t c)
        : _year(a)
        , _month(b)
        , _day(c)
    {}

    bool IsLeapYear() {
        if (((_year % 4 == 0) && (_year % 100 != 0)) || (_year % 400 == 0))
            return true;
        else
            return false;
    }

    size_t GetDayByYMD() {
        vector<size_t> MonthDay{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        if (IsLeapYear()) {
            MonthDay[2] = 29;
        }
        size_t sum = 0;
        for (size_t i = 1; i < _month; i++) {
            sum += MonthDay[i];
        }

        return (sum += _day);
    }
private:
    size_t _year;
    size_t _month;
    size_t _day;
};

int main() {
    size_t a, b, c;
    while (cin >> a >> b >> c) {
        Date d(a, b, c);
        size_t day = d.GetDayByYMD();
        cout << day << endl;
    }